//
//  ResultData.m
//  Kelindo
//
//  Created by Gianluca Puglia on 08/05/13.
//  Copyright (c) 2013 Gianluca Puglia. All rights reserved.
//

#import "ResultData.h"

@implementation ResultData

- (id)initWithAlbums:(NSArray *)a {
    self = [super init];
    if (self) {
        _albums = a;
    }
    return self;
}

- (NSArray *)filterOnlyMatch {
    NSMutableArray *filteredAlbums = [[NSMutableArray alloc] init];
    for (NSDictionary *d in _albums) {
        if ([[d objectForKey:@"status"] isEqualToString:@"MATCH"]) {
            [filteredAlbums addObject:d];
        }
    }
    return filteredAlbums;
}

- (NSArray *)filterAllOrdered {
    NSMutableArray *filteredAlbums = [[NSMutableArray alloc] init];
    for (NSDictionary *d in _albums) {
        if ([[d objectForKey:@"status"] isEqualToString:@"MATCH"]) {
            [filteredAlbums addObject:d];
        }
    }
    for (NSDictionary *d in _albums) {
        if (![[d objectForKey:@"status"] isEqualToString:@"MATCH"]) {
            [filteredAlbums addObject:d];
        }
    }
    return filteredAlbums;
}

@end
